package com.bdqn.tour.servlet.Hqf;

//景点删除servlet

import com.bdqn.tour.service.HqfDeleteService;
import com.bdqn.tour.service.impl.hqfDeleteServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/hqfdelete")
public class HqfDeleteServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //设置编码格式
       req.setCharacterEncoding("UTF-8");
       resp.setCharacterEncoding("UTF-8");
       resp.setContentType("text/html;charset=UTF-8");
       //从请求中获取名id参数转为整数型
       int id = Integer.parseInt(req.getParameter("id"));
       //调用业务层hqfDeleteService
       HqfDeleteService deleteService = new hqfDeleteServiceImpl();
       //调用业务层方法删除景点业务
        int  result = deleteService .deleteScenic(id);
        //通过响应Writer()对象result以字符串写入http中
        resp.getWriter().print(result);
    }
}
